<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="cn.edu.scau.cmi.carol.javabean.Conn" %>
<%@ page import="cn.edu.scau.cmi.carol.sex.Sex" %>
<%@ page import="java.sql.*" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>register_deal</title>
</head>
<body>
<jsp:useBean id="user" class="cn.edu.scau.cmi.carol.javabean.User"></jsp:useBean>
<jsp:setProperty property="*" name="user"/>
<%
try{
Connection conn=Conn.connect();
String insertsql="insert into student (studentID,name,sex,age,password)values(?,?,?,?,?)";
PreparedStatement ps=conn.prepareStatement(insertsql);
ps.setInt(1,user.getStudentID());
ps.setString(2,user.getName());
ps.setInt(3,Sex.sexToInt(user.getSex()));
ps.setInt(4, user.getAge());
ps.setString(5,user.getPassword().toString());
int row=ps.executeUpdate();
if(row>0){
	out.print("ok!");
	
	
}

ps.close();
conn.close();
}
catch(Exception e){
	out.print("failed.");
	e.printStackTrace();
}

%>
<a href="login.jsp" >login</a>
</body>
</html>